import { ref } from 'vue'
import { defineStore } from 'pinia'
import { Api } from '@/types/Api'
import type { BaseDataResult } from '@/types/BaseResult'

export const useCounterStore = defineStore('counterStore', () => {
  const count = ref(0)

  const increment = () => {
    Api.post(
      '/tools/counter/addNoLimit',
      {
        counterKey: 'top.majuan.teach.counter',
      },
      (data: BaseDataResult<number>) => {
        if (data.success) {
          count.value = data.data
        }
      },
    )
  }

  return {
    count,
    increment,
  }
})
